package com.uniledger.exchange.model.api;

import com.uniledger.commonlib.pinkeyboard.PayThirdResult;
import com.uniledger.exchange.home.scheme.PayResult;
import com.uniledger.exchange.login.Admin;
import com.uniledger.exchange.model.HttpResult;
import com.uniledger.exchange.model.StellarAsset;
import com.uniledger.exchange.model.StellarList;
import com.uniledger.exchange.model.User;

import java.util.List;
import java.util.Map;

import io.reactivex.Flowable;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface ApiService {

    @GET("http://www.mocky.io/v2/5b87b9432e0000ac0f05fa47")
    Flowable<HttpResult<User>> getUser();

    /**
     * 发送验证码
     *
     * @return
     */
    @FormUrlEncoded
    @POST("getCaptcha")
    Flowable<HttpResult> getCaptcha(@Field("mobile") String mobile);

    /**
     * 注册
     *
     * @param params
     * @return
     */
    @FormUrlEncoded
    @POST("signup")
//    @POST("http://www.mocky.io/v2/5b87b9432e0000ac0f05fa47")
    Flowable<HttpResult<StellarAsset>> signUp(@FieldMap Map<String, String> params);


    /**
     * 登录
     *
     * @param params
     * @return
     */
    @FormUrlEncoded
    @POST("/signin")
    Flowable<HttpResult<Admin>> signIn(@FieldMap Map<String, String> params);


    /**
     * 获取用户余额
     *
     * @return
     */
    @GET("getBalance")
//    @GET("http://www.mocky.io/v2/5b87c97c2e0000570005faf7")
    Flowable<HttpResult<List<StellarAsset>>> getBalance();

    /**
     * 生成收款码地址
     *
     * @return
     */
    @GET("payThis")
//    @GET(" http://www.mocky.io/v2/5b87cb0a2e0000ab0f05faff")
    Flowable<HttpResult<StellarAsset>> payThis(@Query("amount") String amount, @Query("currency") String currency);

    /**
     * 读取收款码付款信息
     *
     * @return
     */
    @GET("willPay")
//    @GET(" http://www.mocky.io/v2/5b87cdbe2e0000b20d05fb0d")
    Flowable<HttpResult<StellarAsset>> willPay(@Query("paycode") String paycode);

    /**
     * 支付
     *
     * @param params
     * @return
     */
    @FormUrlEncoded
    @POST("doPay")
//    @POST("http://www.mocky.io/v2/5b87d2ea2e0000710c05fb36")
    Flowable<HttpResult<PayResult>> doPay(@FieldMap Map<String, String> params);


    @FormUrlEncoded
    @POST("doCharge")
//    @POST(" http://www.mocky.io/v2/5b87d2ea2e0000710c05fb3")
    Flowable<HttpResult<PayResult>> doCharge(@FieldMap Map<String, String> params);

    /**
     * 转账
     *
     * @return
     */
    @FormUrlEncoded
    @POST("doTransfer")
//    @POST("http://www.mocky.io/v2/5b87d2ea2e0000710c05fb3")
    Flowable<HttpResult<PayResult>> doTransfer(@FieldMap Map<String, String> params);

    @FormUrlEncoded
    @POST("doTransfer")
//    @POST("http://www.mocky.io/v2/5b87d2ea2e0000710c05fb3")
    Flowable<HttpResult<PayThirdResult>> doThirdTransfer(@FieldMap Map<String, String> params);


    /**
     * 取现
     *
     * @return
     */
    @FormUrlEncoded
    @POST("doWithdraw")
//    @POST("http://www.mocky.io/v2/5b87d2ea2e0000710c05fb3")
    Flowable<HttpResult<PayResult>> doWithdraw(@FieldMap Map<String, String> params);

    /**
     * 获取交易历史
     *
     * @param page
     * @param page_size
     * @return
     */
    @GET("getTrxHistory")
//    @GET("http://www.mocky.io/v2/5b8ccf132f00009b0cceeca5")
    Flowable<HttpResult<StellarList>> getTrxHistory(@Query("page") int page, @Query("page_size") int page_size);

    /**
     * 获取通讯列表
     *
     * @return
     */
    @GET("getBuddyList")
//    @GET("http://www.mocky.io/v2/5b87e2712e00009a1e05fbb8")
    Flowable<HttpResult<StellarList>> getBuddyList(@Query("page") int page, @Query("page_size") int page_size);

    /**
     * 通讯录管理 - 添加好友
     *
     * @return
     */
    @FormUrlEncoded
    @POST("addBuddy")
    Flowable<HttpResult> addBuddy(@FieldMap Map<String, String> params);

    /**
     * 通讯录管理 - 删除好友
     *
     * @return
     */
    @FormUrlEncoded
    @POST("removeBuddy")
    Flowable<HttpResult> removeBuddy(@Field("buddy_id") String buddy_id);

    /**
     * 银行卡列表
     *
     * @param page
     * @param page_size
     * @return
     */
    @GET("getBankcardList")
//    @GET("http://www.mocky.io/v2/5b8ca59c2f00009a0cceec4b")
    Flowable<HttpResult<StellarList>> getBankcardList(@Query("page") int page, @Query("page_size") int page_size);

    /**
     * 银行卡管理 - 绑定银行卡
     *
     * @param params
     * @return
     */
    @FormUrlEncoded
    @POST("addBankcard")
    Flowable<HttpResult> addBankcard(@FieldMap Map<String, String> params);

    @FormUrlEncoded
    @POST("removeBankcard")
    Flowable<HttpResult> removeBankcard(@Field("bankcard_id") String bankcard_id);

    @GET("http://free.currencyconverterapi.com/api/v5/convert")
    Flowable<Map<String, String>> convert(@Query("q") String q, @Query("compact") String compact);

    @FormUrlEncoded
    @POST("registerPushDeviceToken")
    Flowable<HttpResult> pushToken(@Field("device_token")String token);

}
